package com.example.administrator.nurse.widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.nurse.R;

/**
 * Created by 林冠宏 on 2016/5/2.
 *
 */

public class ItemImage {

    private View itemImage;
    private Context context;

    public ItemImage(Context context,LinearLayout parent){
        itemImage = LayoutInflater.from(context).inflate(R.layout.image_item,parent,false);
    }

    public ItemImage withImageSrc(int srcId){
        ((ImageView)itemImage.findViewById(R.id.image)).setImageResource(srcId);
        return this;
    }



    public ItemImage withTvText(String str){
        ((TextView)itemImage.findViewById(R.id.text)).setText(str);
        return this;
    }

    /** 如有必要，动态设置大小 */
    public ItemImage withLayoutParam(ViewGroup.LayoutParams lp){
        itemImage.setLayoutParams(lp);
        return this;
    }

    public View init(){
        return itemImage;
    }
}
